package com.shujia.sink

import org.apache.flink.api.common.serialization.SimpleStringSchema
import org.apache.flink.streaming.api.scala._
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer

object Demo2SinkKafka {

  def main(args: Array[String]): Unit = {

    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    val student: DataStream[String] = env.readTextFile("data/students.txt")

    val sinkKafka: FlinkKafkaProducer[String] = new FlinkKafkaProducer[String](
      "master:9092",
      "student",
      new SimpleStringSchema()
    )

    student.addSink(sinkKafka)

    env.execute()

  }

}
